<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<div class="r_location">
	<i class="r_txtico"></i> 用户信息管理 &gt; 贴士发送管理 &gt; 新建贴士
</div>
<form id="qForm" action="tips/add/view" method="post">
	<ul class="all_list">
		
		<li><span class="all_title">通知对象：</span> <span><input
				type="text" class="ui_input " id="roleList"
				validator='{"label":"通知对象","isOnBlurEnable":false}' readonly="readonly" name="roleList"
				style="width: 400px;"></span><span><input type="button" value="选择"
				id="select_role" class="btn_blue m-r15"> </span></li>
		<li><span class="all_title">显示日期：</span> <span>
		<input
				type="text" class="ui_input Wdate" id="displayDateFrom"
				readonly="readonly" name="displayDateFrom" validator='{"label":"显示日期","groupId":"displayDate","isRequiredStyleInUse":false}'
				onclick="var displayDateTo=$dp.$('displayDateTo');WdatePicker({dateFmt:'yyyy-MM-dd',onpicked:function(){displayDateTo.click();},minDate:'%y-%M-%d',maxDate:'#F{$dp.$D(\'displayDateTo\')}'})"> -
				<input
				type="text" class="ui_input Wdate" id="displayDateTo"
				readonly="readonly" name="displayDateTo" validator='{"label":"显示日期","groupId":"displayDate"}'
				onclick="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'displayDateFrom\')}'})">
				</span></li>
		<li><span
				class="all_title">显示时间：</span> <span><input
					maxlength="3" type="text" class="ui_input "
					id="displayTime" validator='{"label":"显示时间","isNZADigit":true,"customFun":"validateDisplayTime","suffixTxt":"(秒)不得超过120秒"}'
					name="displayTime"></span></li>
		<li><span class="all_title">显示次数：</span> <span><input
				type="text" class="ui_input " id="displayCount"
				validator='{"label":"显示次数","isNZADigit":true,"suffixTxt":"显示次数:每天登录显示的次数,如3次,则3次登录,则显示,第4次登录则不显示"}' name="displayCount"><span></span>
		</span></li>
		<li class="m-t10"><span class="all_title">贴士内容：</span> <span><textarea
					validator='{"label":"贴士内容"}' class="ui_input " id="content"
					style="width:500px;height:300px" name="content"></textarea> </span></li>
		<li><span class="all_title"></span><span> <input
				type="button" id="query" value="预览" class="btn_blue m-r15 submitBtn">
				<input type="button" value="重置" class="reset_btn m-r15 resetBtn" id="reset_button">
				<input type="hidden" id="roleListId" name="roleListId">
		</span></li>
	</ul>
</form>
<script>
	$(function() {
		$("#select_role, #roleList").click(function(){
			showDialog('tips/role', {
				width : '600px',
				title : '选择角色',
				lock : true,
				param : {
					roleListId : $("#roleListId").val()
					}
			});
		});
		$("#reset_button").click(function(){
			$("#roleListId").val("");
		});
		function showDialog(url, options) {
			myDialog = art.dialog(options);// 初始化一个带有loading图标的空对话框
			$.post(url, options.param, function(data) {
				myDialog.content(data);
			});
		}
		$("#qForm").validator({}, {
			callback : function(results){
				var param = {};			
				var paramArray = $('#qForm').serializeArray();
				for (var i in paramArray) {
					param[paramArray[i].name] = paramArray[i].value;
				}
				showDialog('tips/add/view', {
					width : '700px',
					title : '预览贴士',
					lock : true,
					param : param
				});
			}
		});
	});
	// 自定义校验显示时间
	function validateDisplayTime() {
		var result = {};
		result.result = true;
		var num = Number($('#displayTime').val());
		if (num > 120) {
			result.result = false;
			result.msg = "显示时间不得超过120秒";
		}
		
		return result;	
	}
</script>